<template>
	<view class="container ptb_8 plr_16">
		<view class="lits_item br_8 bc_fff p_12 pr" v-for="item,index in dataList" :key="index">
			<image class="pa t_14 r_8 zi_1 width_16 height_16" src="@/static/images/delete.png" mode=""
				@click="handleDelete(item)"></image>
			<GoodsCard type="evaluate-detail-card" :data="item" :toDetail="false"></GoodsCard>
			<view class="mt_12">
				<view class="fx">
					<view class="width_68 fz_14 fc_999">
						评价时间
					</view>
					<view class="fx_1 fz_14">
						{{item.createTime||''}}
					</view>
				</view>
			</view>
			<view class="mt_18">
				<view class="fx aic">
					<view class="width_68 fz_14 fc_999">
						商品质量
					</view>
					<view class="fx_1 fz_14">
						<u-rate :value="item.scoreLevel" :count="5" activeColor="#D70000" size="48rpx"
							:readonly="true"></u-rate>
					</view>
				</view>
			</view>
			<view class="mt_18">
				<view class="fx">
					<view class="width_68 fz_14 fc_999">
						商品评价
					</view>
					<view class="fx_1 fz_14">
						{{item.evaluateContent||'该用户暂未评价！'}}
					</view>
				</view>
			</view>
			<view class="mt_12 fx fx_w imgs_wrap">
				<view class="pr" v-for="item1,index1 in evaluateImageList(item)" :key="index">
					<CustomImage width="196rpx" height="196rpx" radius="16rpx" :src="item1"
						@click.native="$utils.handlePreview(index1,evaluateImageList(item))" />
				</view>
			</view>
			<view class="mt_16 pt_6 pb_6 pl_12 pr_12 bc_ reply br_4" v-if="item.replyContent">
				<text class="fc_r">店小二：</text>
				<text>{{item.replyContent||''}}</text>
			</view>
		</view>
		<view class="pt_16" v-if="dataList.length">
			<u-loadmore :status="loadingStatus" />
		</view>
		<view class="pt_100" v-if="!loading&&!dataList.length">
			<Empty title="暂无评价" />
		</view>
	</view>
</template>

<script>
	import GoodsCard from '@/components/goods/GoodsCard.vue'
	import CustomImage from "@/components/Image.vue"
	import Empty from '@/components/Empty.vue'
	import dataMixin from '@/mixins/data.js'
	import api from '@/service/config/api.js'
	export default {
		mixins: [dataMixin],
		components: {
			GoodsCard,
			Empty,
			CustomImage
		},
		data() {
			return {
				dataList: [],
				listUrl: '/goods/api/productEvaluate/pageList',
			};
		},
		computed: {
			evaluateImageList() {
				return data => data.evaluateImageUrl ? data.evaluateImageUrl.split(',') : []
			},
		},
		onLoad() {
			this.getData(true)
		},
		methods: {
			handleDelete(data) {
				if (data.id) {
					this.$utils.showModal({
						title: '提示',
						content: '确认删除该评价？'
					}).then(() => {
						this.$utils.loading()
						api.get('/goods/api/productEvaluate/delete/' + data.id).then(res => {
							this.$utils.showToast('删除成功', 1500, 1, '', 'success')
						})
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.lits_item+.lits_item {
		margin-top: 16rpx;
	}

	.imgs_wrap {
		grid-row-gap: 18rpx;
		grid-column-gap: 18rpx;
	}
</style>